package org.groupg.filetodb.model.database;


import com.google.common.base.MoreObjects;
import com.google.common.base.Objects;

/**
 * 表示存储过程参数元数据
 */
public class ProcedureColumn {
    /**
     * 过程目录
     */
    private String procedureCat;
    /**
     * 过程模式
     */
    private String procedureSchem;
    /**
     * 过程名称
     */
    private String procedureName;
    /**
     * 参数名称
     */
    private String columnName;
    /**
     * 参数类型（DatabaseMetaData.procedureColumnXXX常量）
     */
    private short columnType;
    /**
     * SQL类型 (java.sql.Types)
     */
    private int dataType;
    /**
     * 数据库类型名
     */
    private String typeName;
    /**
     * 精度
     */
    private int precision;
    /**
     * 数据长度（字节）
     */
    private int length;
    /**
     * 小数位数
     */
    private short scale;
    /**
     * 基数
     */
    private short radix;
    /**
     * 是否允许NULL（DatabaseMetaData.procedureNullableXXX常量）
     */
    private short nullable;
    /**
     * 参数注释
     */
    private String remarks;
    /**
     * 默认值
     */
    private String columnDef;
    /**
     * SQL数据类型（未使用）
     */
    private int sqlDataType;
    /**
     * 日期时间子类型（未使用）
     */
    private int sqlDatetimeSub;
    /**
     * 字符列的最大字节长度
     */
    private int charOctetLength;
    /**
     * 参数位置（从1开始）
     */
    private int ordinalPosition;
    /**
     * "YES"/"NO"/"" 表示是否可空
     */
    private String isNullable;
    /**
     * 特定名称（唯一标识）
     */
    private String specificName;

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("procedureCat", procedureCat)
                .add("procedureSchem", procedureSchem)
                .add("procedureName", procedureName)
                .add("columnName", columnName)
                .add("columnType", columnType)
                .add("dataType", dataType)
                .add("typeName", typeName)
                .add("precision", precision)
                .add("length", length)
                .add("scale", scale)
                .add("radix", radix)
                .add("nullable", nullable)
                .add("remarks", remarks)
                .add("columnDef", columnDef)
                .add("sqlDataType", sqlDataType)
                .add("sqlDatetimeSub", sqlDatetimeSub)
                .add("charOctetLength", charOctetLength)
                .add("ordinalPosition", ordinalPosition)
                .add("isNullable", isNullable)
                .add("specificName", specificName)
                .toString();
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) return false;
        ProcedureColumn that = (ProcedureColumn) o;
        return getColumnType() == that.getColumnType() && getDataType() == that.getDataType() && getPrecision() == that.getPrecision() && getLength() == that.getLength() && getScale() == that.getScale() && getRadix() == that.getRadix() && getNullable() == that.getNullable() && getSqlDataType() == that.getSqlDataType() && getSqlDatetimeSub() == that.getSqlDatetimeSub() && getCharOctetLength() == that.getCharOctetLength() && getOrdinalPosition() == that.getOrdinalPosition() && Objects.equal(getProcedureCat(), that.getProcedureCat()) && Objects.equal(getProcedureSchem(), that.getProcedureSchem()) && Objects.equal(getProcedureName(), that.getProcedureName()) && Objects.equal(getColumnName(), that.getColumnName()) && Objects.equal(getTypeName(), that.getTypeName()) && Objects.equal(getRemarks(), that.getRemarks()) && Objects.equal(getColumnDef(), that.getColumnDef()) && Objects.equal(getIsNullable(), that.getIsNullable()) && Objects.equal(getSpecificName(), that.getSpecificName());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getProcedureCat(), getProcedureSchem(), getProcedureName(), getColumnName(), getColumnType(), getDataType(), getTypeName(), getPrecision(), getLength(), getScale(), getRadix(), getNullable(), getRemarks(), getColumnDef(), getSqlDataType(), getSqlDatetimeSub(), getCharOctetLength(), getOrdinalPosition(), getIsNullable(), getSpecificName());
    }

    public String getProcedureCat() {
        return procedureCat;
    }

    public void setProcedureCat(String procedureCat) {
        this.procedureCat = procedureCat;
    }

    public String getProcedureSchem() {
        return procedureSchem;
    }

    public void setProcedureSchem(String procedureSchem) {
        this.procedureSchem = procedureSchem;
    }

    public String getProcedureName() {
        return procedureName;
    }

    public void setProcedureName(String procedureName) {
        this.procedureName = procedureName;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public short getColumnType() {
        return columnType;
    }

    public void setColumnType(short columnType) {
        this.columnType = columnType;
    }

    public int getDataType() {
        return dataType;
    }

    public void setDataType(int dataType) {
        this.dataType = dataType;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public int getPrecision() {
        return precision;
    }

    public void setPrecision(int precision) {
        this.precision = precision;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }

    public short getScale() {
        return scale;
    }

    public void setScale(short scale) {
        this.scale = scale;
    }

    public short getRadix() {
        return radix;
    }

    public void setRadix(short radix) {
        this.radix = radix;
    }

    public short getNullable() {
        return nullable;
    }

    public void setNullable(short nullable) {
        this.nullable = nullable;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getColumnDef() {
        return columnDef;
    }

    public void setColumnDef(String columnDef) {
        this.columnDef = columnDef;
    }

    public int getSqlDataType() {
        return sqlDataType;
    }

    public void setSqlDataType(int sqlDataType) {
        this.sqlDataType = sqlDataType;
    }

    public int getSqlDatetimeSub() {
        return sqlDatetimeSub;
    }

    public void setSqlDatetimeSub(int sqlDatetimeSub) {
        this.sqlDatetimeSub = sqlDatetimeSub;
    }

    public int getCharOctetLength() {
        return charOctetLength;
    }

    public void setCharOctetLength(int charOctetLength) {
        this.charOctetLength = charOctetLength;
    }

    public int getOrdinalPosition() {
        return ordinalPosition;
    }

    public void setOrdinalPosition(int ordinalPosition) {
        this.ordinalPosition = ordinalPosition;
    }

    public String getIsNullable() {
        return isNullable;
    }

    public void setIsNullable(String isNullable) {
        this.isNullable = isNullable;
    }

    public String getSpecificName() {
        return specificName;
    }

    public void setSpecificName(String specificName) {
        this.specificName = specificName;
    }
}